
import os
import sys
import pygame
from inkface.pygame import PygameFace, PygameCanvas

class App:
    def main(self):
        self.face = PygameFace(sys.argv[1])

        if os.environ.get('INKFACE_FULLSCREEN') is not None:
            flags = pygame.FULLSCREEN
        else:
            flags = 0

        self.canvas = PygameCanvas(
            (int(self.face.svg.width),int(self.face.svg.height)),
            flags = flags,
            framerate = 0)

        self.face.hideButton.onLeftClick = self.handleHide
        self.face.unhideButton.onLeftClick = self.handleUnhide
        self.canvas.add(self.face)
        self.canvas.paint()
        try:
            self.canvas.eventloop()
        except KeyboardInterrupt, ki:
            sys.exit(0)
 
    def handleHide(self, elem):
        self.face.theobj.hide()
        self.canvas.paint()

    def handleUnhide(self, elem):
        self.face.theobj.unhide()
        self.canvas.paint()

App().main()
